#include "DXUT.h"
#include "BoundRect.h"




//DWORD RECTVERTEX::FVF=D3DFVF_DIFFUSE|D3DFVF_XYZ|;




CBoundRect::CBoundRect( float x, float y, float r )	:   m_min(x-r,y-r),m_max(x+r,y+r)
{
}

CBoundRect::CBoundRect( float x1, float y1, float x2,float y2 )	   : m_min(x1,y1),m_max(x2,y2)
{
}


CBoundRect::~CBoundRect(void)
{
}

bool CBoundRect::IsCross( const CBoundRect & rt )
{
	if(m_min.x>rt.m_max.x  || m_min.y >rt.m_max.y) return false;
	if(m_max.x<rt.m_min.x|| m_max.y<rt.m_min.y) return false;
	return true;
}

void CBoundRect::Render(const bool bIsSameColor)
{
	CPrimiteRender::Instance()->DrawRect(m_min.x,m_min.y,m_max.x,m_max.y,bIsSameColor);
}

void CBoundRect::SetBoundRect( float x1,float y1,float x2,float y2 )
{
	m_min=D3DXVECTOR2(x1,y1);	  
	m_max= D3DXVECTOR2(x2,y2);

 
}

void CBoundRect::SetBoundRect( float x, float y, float r )
{
	m_min=D3DXVECTOR2(x-r,y-r);m_max=D3DXVECTOR2(x+r,y+r);
}

 


bool CBoundRect::IsPointIn( int x, int y )
{
	if( x>m_max.x||y>m_max.y ||   x<m_min.x||y<m_min.y )  return false;
	return true;
}
